/*
 * @Author: your name
 * @Date: 2021-04-02 15:50:21
 * @LastEditTime: 2021-05-31 15:20:13
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \egg-demo\app\service\admins.js
 */
'use strict';

const { Service } = require('egg');

class AdminsService extends Service {
  async list() {
    const adminList = await this.ctx.model.Admins.findAll();
    return adminList;
  }

  async create() {
    // const { name, age, isAble, province_code, city_code, county_code, address, idNumber } = this.ctx.request.body;
    const { ctx } = this;
    const demo = {
      name: '丘处机',
      age: 53,
      is_able: true,
      province_code: 42,
      county_code: 32,
      city_code: 12,
      address: '北疆',
      id_number: '320102199503014172',
    };
    // const admin = await this.ctx.model.Admins.create({ name, age, isAble, province_code, city_code, county_code, address, idNumber })
    return ctx.model.Admins.create({
      ...demo,
    });
  }

  async findItem() {
    const { uuid } = this.ctx.request.query;
    const adminInfo = await this.ctx.model.Admins.findOne({
      where: { uuid },
    });

    return adminInfo;
  }
}

module.exports = AdminsService;

